<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>jQuery UI Portlet</title>
    <link rel="stylesheet" href="../lib/bootstrap/css/bootstrap.min.css" />
    <!-- jquery 1.4 and jquery ui 1.8 -->
    <link rel="stylesheet" href="../lib/themes/bootstrap/jquery-ui-1.10.0.custom.css" />
    <link rel="stylesheet" href="../lib/themes/bootstrap/jquery.ui.1.10.0.ie.css" />
    <link rel="stylesheet" href="../css/jquery.portlet.css?v=1.1.3" />

    <script src="../lib/jquery-1.8.3.min.js" type="text/javascript"></script>
    <script src="../lib/jquery-ui-1.10.2.custom.min.js" type="text/javascript"></script>

    <!--<link rel="stylesheet" href="../lib/themes/1.9/start/jquery-ui-1.9.1.custom.min.css" />-->
    <!--<script src="../lib/jquery-1.8.3.js" type="text/javascript"></script>-->
    <!--<script src="../lib/themes/jquery-ui-1.9.1.custom.min.js" type="text/javascript"></script>-->

    <script src="../script/jquery.portlet.pack.js?v=1.1.3"></script>
    <style>
    body {font-size: 13px;}
    .highlight-content {color: red;}
    </style>
    <script>
    $(function() {
        $('#portlet-demo').portlet({
            sortable: true,
            create: function() {
                //alert('created portlet.');
            },
            removeItem: function() {
                alert('after remove');
            },
            columns: [{
                width: 400,
                portlets: [{
                    attrs: {
                        id: 'feeds'
                    },
                    title: function() {
                        var d = new Date();
                        return 'Feeds(' + (d.getMonth() + 1) + '-' + d.getDay() + '日)';
                    },
                    icon: 'ui-icon-signal-diag',
                    content: {
                        //设置区域内容属性
                        style: {
                            height: '100'
                        },
                        type: 'text',
                        text: '<ul><li>Feed item 1</li><li>Feed item 2</li></ul>',
                        beforeShow: function(aa) {
                            //alert('before show, content is: ' + aa);
                        },
                        afterShow: function() {
                            //alert('after show');
                        }
                    },
                    scripts: ['loaded-by-portlet.js']
                }, {
                    attrs: {
                        id: 'news'
                    },
                    title: '主题整合支持',
                    beforeRefresh: function() {
                        alert("before refresh");
                    },
                    afterRefresh: function(data) {
                        //alert("after refresh: " + data);
                    },
                    content: {
                        style: {
                            height: '300'
                        },
                        type: 'text',
                        text: function() {
                            return $('#newsTemplate').html();
                            //return $('#newsTemplate ul');
                        }
                    }
                }]
            }, {
                width: 350,
                portlets: [{
                    title: 'Code',
                    content: {
                        type: 'text',
                        text: function() {
                            return $('#code').html();
                        }
                    }
                }, {
                    title: 'Ajax 错误',
                    content: {
                        type: 'ajax',
                        url: 'noexsit.html',
                        error: function() {
                            $(this).append('<br/><br/>捕获到ajax错误');
                            // alert('出错了');
                        }
                    }
                }, {
                    title: 'Table',
                    content: {
                        type: 'text',
                        text: function() {
                            return $('#tableTemplate').html();
                        }
                    }
                }]
            }]
        });
    });
    </script>
</head>
<body>
    <div class="ui-state-highlight ui-corner-all" style="padding: 0 .7em;">
        <p>
            <i class="icon-heart"></i>使用Bootstrap主题（由jQuery UI的Bootstrap主题风格支持）
        </p>
    </div>
    <hr class='ui-widget-content' />
    <div id='portlet-demo'></div>

    <!-- 模板 -->
    <div id="newsTemplate" style="display:none">
        <a href="http://addyosmani.github.com/jquery-ui-bootstrap/">http://addyosmani.github.com/jquery-ui-bootstrap/</a>
        <hr/>
        <p class="text-warning">警告信息。</p>
        <p class="text-error">错误信息。</p>
        <p class="text-info">提示信息。</p>
        <p class="text-success">成功信息。</p>
        <button class="btn btn-primary">Bootstrap的按钮</button>
    </div>

    <div id="tableTemplate" style="display:none">
        <table class="table table-bordered table-hover">
          <thead>
            <tr>
              <th>#</th>
              <th>First Name</th>
              <th>Last Name</th>
              <th>Username</th>
            </tr>
          </thead>
          <tbody>
            <tr>
              <td>1</td>
              <td>Mark</td>
              <td>Otto</td>
              <td>@mdo</td>
            </tr>
            <tr>
              <td>2</td>
              <td>Jacob</td>
              <td>Thornton</td>
              <td>@fat</td>
            </tr>
            <tr>
              <td>3</td>
              <td>Larry</td>
              <td>the Bird</td>
              <td>@twitter</td>
            </tr>
          </tbody>
        </table>
    </div>

    <div id="code" style="display:none">
        <code>.highlight-content {color: red;}</code>
    </div>
</body>
</html>